package com.huangliusong;

import com.huangliusong.VO.AuditVO;
import com.huangliusong.VO.RequestVO;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huangliusong
 * @since 2019/4/1
 * {@link }
 */
@RestController
@RequestMapping(value = "/v1")
public class Controller {
    @RequestMapping(value = "/create")
    public String create(@Validated @RequestBody RequestVO<AuditVO> vo, BindingResult bindingResult
                         ){
        if (bindingResult.hasErrors()){
            System.out.println(bindingResult.getFieldError().getDefaultMessage());
            return "error";
        }
        System.out.println(vo.getData());
        if (vo.getData().getName()==null){
            System.out.println("是空");
        }
        return "huang";
    }

    @RequestMapping(value = "/create1")
    public String create(@Validated @RequestBody AuditVO vo, BindingResult bindingResult
    ){
        if (bindingResult.hasErrors()){
            System.out.println(bindingResult.getFieldError().getDefaultMessage());
            return "error";
        }
        System.out.println(vo);
        if (vo.getName()==null){
            System.out.println("是空");
        }
        return "huang";
    }
}
